home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / FNTNS / TLI.ASM < prev    next >
Assembly Source File  |  1989-01-24  |  3KB  |  87 lines

  1. ;
  2. ; This program originally available on the Motorola DSP bulletin board.
  3. ; It is provided under a DISCLAMER OF WARRANTY available from
  4. ; Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735.
  5. ; Linear Table Lookup/Interpolation Routine for Function Generation
  6. ; Last Update 16 Apr 87   Version 1.1
  7. ;
  8. ;   This program provides a fixed-point implementation of a table
  9. ;   lookup/interpolation (of form given in TLI.HLP).
  10. ;
  11. ;       The example will generate a 255 point sine wave by
  12. ;       interpolating between the points of a 17 point sine wave.
  13. ;
  14.         opt     cex,mex
  15.         page    132,66,0,10
  16.  
  17. dataout equ     $fffe                   ; output file
  18. deg     equ     3.141592654/180.0       ;conversion from radians to degrees
  19.  
  20.         org     x:$10
  21. ;
  22. ;       Function points Y(i)=f(X(i)): Sine wave of magnitude 1/2
  23. ;
  24. bptbl                                   ;breakpoint table for function
  25.         dc      @sin(0.0*deg)/2.0
  26.         dc      @sin(22.5*deg)/2.0
  27.         dc      @sin(45.0*deg)/2.0
  28.         dc      @sin(67.5*deg)/2.0
  29.         dc      @sin(90.0*deg)/2.0
  30.         dc      @sin(112.5*deg)/2.0
  31.         dc      @sin(135.0*deg)/2.0
  32.         dc      @sin(157.5*deg)/2.0
  33.         dc      @sin(180.0*deg)/2.0
  34.         dc      @sin(202.5*deg)/2.0
  35.         dc      @sin(225.5*deg)/2.0
  36.         dc      @sin(247.5*deg)/2.0
  37.         dc      @sin(270.0*deg)/2.0
  38.         dc      @sin(292.5*deg)/2.0
  39.         dc      @sin(315.0*deg)/2.0
  40.         dc      @sin(337.5*deg)/2.0
  41.         dc      @sin(360.0*deg)/2.0
  42.  
  43. n       equ     4                       ;number of bits in X(i)
  44.  
  45.         org     p:$100
  46. ;
  47. ;       Start of program
  48. ;
  49.         move    #-1.0,a                 ;initial angle =0 degrees
  50. ;       note: A will vary from -1.0 to 1.0 to represent an angle
  51. ;             varying from 0.0 to 360.0
  52.         move    a,x:0                   ;save it
  53.         do      #255,_esine             ;do 255 steps
  54.  
  55.  
  56. ;
  57. ;       table lookup/interpolation routine
  58. ;
  59.         clr     b  #$80,x0              ;mask for sign flip
  60.         add     x0,a  #>bptbl,x0        ;flip sgn bit, point to fcn tbl
  61.         do      #n,_es                  ;shift n bits into b
  62.         lsl     a                       ;to become the index into the
  63.         rol     b                       ;function breakpoint table
  64. _es
  65.         add     x0,b  #0,a2             ;add base to ptr, make A positive
  66.         lsr     a  b1,r0                ;make A a fraction, move ptr
  67. ;                               This produces 2**(n-1) (X-X(i))
  68. ;                       Which is equal to (X-X(i))/(X(i+1)-X(i))
  69.         move    a,x0                    ;move A for later mul
  70.         move    x:(r0)+,b               ;get Y(i)
  71.         move    x:(r0),a                ;get Y(i+1)
  72.         sub     b,a                     ;find Y(i+1)-Y(i)
  73.         move    a,y0                    ;move Y(i+1)-Y(i)
  74.         macr    y0,x0,b         ;find Y(i)+(Y(i+1)-Y(i))*(X-X(i))/2**(n-1)
  75. ;
  76. ;       end of routine
  77. ;
  78.         move    b,y:dataout             ;output data
  79.         move    x:0,a                   ;get angle
  80.         move    #$01,x0                 ;angle increment (fractional)
  81.         add     x0,a                    ;increase angle
  82.         move    a,x:0                   ;save output
  83. _esine
  84.         end
  85.